package parser

import (
	"cn.hughie/learngo/crawler1/engine"
	"regexp"
)

//todo 切换常量
var cl = regexp.MustCompile(`<a href="(http://www.zhenai.com/zhenghun/[a-zA-Z0-9]+)"[^>]*>([^<]+)</a>`)

func CityListParser(contents []byte) engine.ParseResult {
	submatch := cl.FindAllSubmatch(contents, -1)
	result := engine.ParseResult{}
	j := 0
	for _, i := range submatch {
		j ++
		if j == 3{
			break
		}
		//result.Items = append(result.Items, string(i[2])+" : "+string(i[1]))
		result.Requests = append(result.Requests, engine.Request{
			Url:       string(i[1]),
			ParseFunc: CityParser,
		})
	}
	return result
}
